#include <ntddk.h>

VOID
DriverUnload(_In_ PDRIVER_OBJECT DriverObject);

VOID
IoWorkitemRoutine(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PVOID Context);

EXTERN_C
NTSTATUS
DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegisterPath)
{
	DriverObject->DriverUnload = DriverUnload;

	UNICODE_STRING DevName = RTL_CONSTANT_STRING(L"\\Device\\MyDevName");

	PDEVICE_OBJECT DeviceObject;
	NTSTATUS CreateDeviceStatus = IoCreateDevice(
		DriverObject,
		0,
		&DevName,
		FILE_DEVICE_UNKNOWN,
		0,
		FALSE,
		&DeviceObject);
	if (NT_SUCCESS(CreateDeviceStatus) == FALSE) {
		KdPrint(("IoCreateDevice Error: 0x%X\n", CreateDeviceStatus));
		return CreateDeviceStatus;
	}

	IoQueueWorkItem(
		IoAllocateWorkItem(DeviceObject),
		IoWorkitemRoutine, 
		CriticalWorkQueue,
		nullptr);

	KdPrint(("Driver loaded successfully\n"));

	return STATUS_SUCCESS;
}

VOID
DriverUnload(_In_ PDRIVER_OBJECT DriverObject)
{
	IoDeleteDevice(DriverObject->DeviceObject);

	KdPrint(("Driver uninstalled successfully\n"));
}

VOID
IoWorkitemRoutine(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PVOID Context)
{
	KdPrint(("IoWorkitemRoutine: Hello World\n"));
}